package com.njlime.sys.entities;

import com.njlime.core.base.entities.BaseEntityPlus;
import com.njlime.core.web.validation.annotation.Validate;

import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 * 角色实体
 * Created by Dean on 2017-7-18.
 */
@Entity
@Table(name = "t_role")
public class Role extends BaseEntityPlus {
    @Validate(description = "所属单位", nullable = false)
    private Integer unit_id; //单位ID
    @Validate(description = "角色名称", nullable = false)
    private String name; //角色名称
    @Validate(description = "英文名称", nullable = false)
    private String name_en; //英文名称
    private Integer status; //角色状态(1有效 0无效)
    @Validate(description = "数据范围", nullable = false)
    private Integer data_scope; //角色数据范围类型

    @Transient
    private String unit_ids;//数据范围明细
    @Transient
    private String menu_ids;//角色菜单id字符串
    @Transient
    private Unit unit;
    @Transient
    private String user_name;

    /**
     * 角色数据范围类型
     * UNIT_ALL 全部
     * UNIT_AND_CHILD 所属及子单位
     * UNIT_ONLY 所属单位
     * SELF_ONLY 仅自己
     * ROLE_SET_UNIT 明细设置
     */
    public static class DataScope {
        public static final int UNIT_ALL = 1;
        public static final int UNIT_AND_CHILD = 2;
        public static final int UNIT_ONLY = 3;
        public static final int SELF_ONLY = 4;
        public static final int ROLE_SET_UNIT = 9;
    }

    public Integer getUnit_id() {
        return unit_id;
    }

    public void setUnit_id(Integer unit_id) {
        this.unit_id = unit_id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getName_en() {
        return name_en;
    }

    public void setName_en(String name_en) {
        this.name_en = name_en;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Integer getData_scope() {
        return data_scope;
    }

    public void setData_scope(Integer data_scope) {
        this.data_scope = data_scope;
    }

    public String getUnit_ids() {
        return unit_ids;
    }

    public void setUnit_ids(String unit_ids) {
        this.unit_ids = unit_ids;
    }

    public String getMenu_ids() {
        return menu_ids;
    }

    public void setMenu_ids(String menu_ids) {
        this.menu_ids = menu_ids;
    }

    public Unit getUnit() {
        return unit;
    }

    public void setUnit(Unit unit) {
        this.unit = unit;
    }

    public String getUser_name() {
        return user_name;
    }

    public void setUser_name(String user_name) {
        this.user_name = user_name;
    }
}
